<?php namespace kisay\EventHandler;

class UserEventHandler
{
    /*
     *订阅用户事件
     */
    public function subscribe($event)
    {
        $event->listen('user.register', 'kisay\EventHandler\UserEventHandler@onUserRegister');
        $event->listen('user.login', 'kisay\EventHandler\UserEventHandler@onUserLogin');
        $event->listen('user.logout', 'kisay\EventHandler\UserEventHandler@onUserLogout');
    }

    public function onUserLogin($user){
        echo 'user login event fired';
        dd($user->toArray());
    }

    public function onUserLogout(){
        echo 'user login event fired';
    }

    /*
     *注册新用户
     */
    public function onUserRegister(){
        echo 'user login event fired';
    }

    /*
     *用户登录失败会记录日志，同时会累计失败次数，做到限制登录
     */
    public function onUserFailed(){

    }
}

